<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>创建合同订单</title>
    <%@ include file="/WEB-INF/views/include/head.jsp"%>
    <script src="${ctxStatic}/js/jquery-1.9.1.min.js"></script>
    <script src="${ctxStatic}/js/DateTimePicker.js"></script>
    <script src="${ctxStatic}/js/layer.js"></script>
    <script src="${ctxStatic}/js/style.js"></script>
    <script src="${ctxStatic}/dateCalendar/WdatePicker.js"></script>
    <link rel="stylesheet" href="${ctxStatic}/css/common.css">
    <link rel="stylesheet" href="${ctxStatic}/css/layerSm.css">
    <script type="text/javascript">
    $(document).ready(function(){
    	$("#contractClause").select2();
    	getClause();
    });
    
    function getClause() {
    	var type = $("#contractClause").val();
    	type =  type.charAt(type.length - 1);
    	param = {"clauseType":type};
    	$.post("${ctx}/purchase/contract/getClause",param,function(result){
    		/* 弹出提示框,刷新父页面,关闭当前页面 */
    		var contractClause = result["contractClause"];
    		$("#clauseHtml").html(contractClause);
    		var clauseType = result["clauseType"];
    		$("#clauseType").val(clauseType);
    	},'json');
	}
    
    function sendClause() {
    	//获取 iframe 数量 
    	var frLength = window.parent.frames.length;
    	//父画面下标 
    	var parentIndex = frLength-2;
    	window.parent.frames[parentIndex].$("#contractClause").html($("#clauseHtml").html());
    	window.parent.frames[parentIndex].$("#paymentWayText").val("");
    	window.parent.frames[parentIndex].$("#clauseTypeTemp").val($("#clauseType").val());
    	window.parent.frames[parentIndex].updateClause();
    	closeWin();
	}
   </script>
</head>
<body>   

<div id="createHead" class="layerHeader clearfix">
	<p class="headerTitle"><spring:message code="purchaseContract_clause_selectClause"/></p>
    <div class="headerButton clearfix">
    <button type="button" onclick="sendClause()"><spring:message code="purchaseContract_clause_selected"/></button>
        <button type="button" onclick="closeWin()"><spring:message code="purchaseContract_supplier_cancle"/></button>
    </div>
</div>

<div id="showHtml" class="smOrderBox">
    <div class="items clearfix">
        <div class="clearfix">
   		<c:set value="CONTRACT_CLAUSE" var="clauseList"/>
        <!-- 合同条款类别  -->
            <p class="tit" style="width: 90px"><spring:message code="purchaseContract_clause_category"/></p>
            <select id="contractClause" style="width: 150px" onchange="getClause();">
                 <c:forEach items="${fns:getDictList(clauseList) }" var="clause">
                 	<c:if test="${purchaseContract.clauseFlag==0}">
                 		<c:if test="${clause.itemValue!='TYPE_02'}">
                     		<option value="${clause.itemCode}-${clause.itemValue}">${clause.itemName}</option>
                     	</c:if>
                   	</c:if>
                   	<c:if test="${purchaseContract.clauseFlag!=0}">
                 		<c:if test="${clause.itemValue=='TYPE_02'}">
                     		<option value="${clause.itemCode}-${clause.itemValue}">${clause.itemName}</option>
                     	</c:if>
                   	</c:if>
                 </c:forEach>
              </select>
        </div>
        
    </div>
    <div class="items clearfix">
        <div class="clearfix" style="overflow: auto;width: 860px;height: 470px">
            <textarea id="clauseHtml" style="width: 860px;height: 470px"></textarea>
            <input type="hidden" id = "clauseType" name="clauseType" value=""/>
        </div>
    </div>
</div>
<script>

</script>
</body>
</html>
